package com.aysafety.iotdataplatformweb.services.comprehensiveWarning.impl;

import com.aysafety.core.common.DateUtils;
import com.aysafety.iotdataplatformweb.common.PythonAlgorithmUtils;
import com.aysafety.iotdataplatformweb.dao.*;
import com.aysafety.iotdataplatformweb.services.comprehensiveWarning.ComprehensiveWarningService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.*;

/**
 * @program: iotDataPlatform
 * @description: 矿-综合预警
 * @author: ChengQi
 * @create: 2019-01-15 09:48
 **/
@Service
public class ComprehensiveWarningServiceImpl implements ComprehensiveWarningService {

    @Autowired
    MicroseismDao microseismDao;
    @Autowired
    PythonAlgorithmUtils pythonAlgorithmUtils;
    @Autowired
    GeosoundDao geosoundDao;
    @Autowired
    ComprehensiveWarningDao comprehensiveWarningDao;
    @Autowired
    TreeDao treeDao;
    @Autowired
    HydraulicsupportDao hydraulicsupportDao;

    private static List<Map<String, Object>> removeDuplicateWithOrder(List<Map<String, Object>> list) {
        Set<Map<String, Object>> set = new HashSet();
        List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>();
        for (int i = 0; i < list.size(); i++) {
            Map<String, Object> map = new HashMap<String, Object>(2);
            map.put("entId", list.get(i).get("entId"));
            map.put("workingFace", list.get(i).get("workingFace"));
            map.put("deviceId", list.get(i).get("deviceId"));
            if (set.add(map)) {
                newList.add(map);
            }
        }
        return newList;
    }

    /**
     * @Description: 将2个list按时间去拉伸
     * @Param: []
     * @return: void
     * @Author: ChengQi
     * @Date: 2019/3/25
     */
    private static void straightenList() {

    }

    /**
     * @Description: 微震综合预警
     * @Param: [mineId, startTime, endTime]
     * @return: java.util.Map<java.lang.String, java.lang.Object>
     * @Author: ChengQi
     * @Date: 2019/3/12
     */
    @Override
    public Map<String, Object> comprehensiveWarningMicroseism(String mineId, String startTime, String endTime)
            throws Throwable {
        //实时能量一年的量
        long startTimeTimestamp = DateUtils.fomatDateTime(startTime).getTime();
        long endTimeTimestamp = DateUtils.fomatDateTime(endTime).getTime();
        Map<String, Object> parram = new HashMap<String, Object>();

        //获取系统参数
        parram.put("tableId", "sysParameter");
        parram.put("pk", "\'" + mineId + ".Microseism" + "\'");
        Map<String, Object> sysParameter = microseismDao.querySys(parram);
        parram.remove("pk");
        //获取近一年的微震数据
        parram.put("tableId", mineId + "." + "MicroseismRealTime");
        parram.put("entId", "\'" + mineId + "\'");
        parram.put("startTime", "\'" + startTimeTimestamp + "\'");
        parram.put("endTime", "\'" + endTimeTimestamp + "\'");
        List<Map<String, Object>> realList = microseismDao.queryRealMicroseism(parram);
        //标记大能量事件的下标
        double largeEmergoa = Double.parseDouble(sysParameter.get("LARGEENERGY").toString());
        List<Integer> largeList = new LinkedList<Integer>();
        List<Double> eList = new LinkedList<Double>();
        for (int i = 0; i < realList.size(); i++) {
            eList.add(Double.parseDouble(realList.get(i).get("emergoa").toString()));
            if (Double.parseDouble(realList.get(i).get("emergoa").toString()) > largeEmergoa) {
                largeList.add(i);
            }
        }
        //取出频次比
        parram.put("tableId", mineId + "." + "CalMicroseism");
        List<Double> cList1 = microseismDao.queryEnergyDeviation1(parram);

        //取出离散度
        parram.put("tableId", mineId + "." + "calDispersion");
        List<Double> cList2 = microseismDao.queryDispersion1(parram);
        //5.综合预警
        Map<String, Object> reqMap = new HashMap<String, Object>();
        reqMap.put("nengliang", eList);
        reqMap.put("pingci", cList1);
        reqMap.put("lisan", cList2);
        reqMap.put("shigu", largeList);
        reqMap.put("choose", "nengliang,pingci,lisan");
        //计算2次算出2组临界值及R值
        Map<String, Object> rsp1 = pythonAlgorithmUtils.serviceGenetic(reqMap);
        Map<String, Object> rsp2 = pythonAlgorithmUtils.serviceGenetic(reqMap);
        System.out.println(rsp1);
        System.out.println(rsp2);
        //保存临界值及R值
        String bests1[] = rsp1.get("best").toString().substring(1, rsp1.get("best").toString().length() - 1).split(",");
        String bests2[] = rsp2.get("best").toString().substring(1, rsp2.get("best").toString().length() - 1).split(",");

        double best1 = Double.parseDouble(bests1[0]);
        double best2 = Double.parseDouble(bests1[1]);
        double best3 = Double.parseDouble(bests1[2]);
        double T1 = Double.parseDouble(bests1[3]);
        double R1 = Double.parseDouble(rsp1.get("fitness").toString());
        double best4 = Double.parseDouble(bests2[0]);
        double best5 = Double.parseDouble(bests2[1]);
        double best6 = Double.parseDouble(bests2[2]);
        double T2 = Double.parseDouble(bests2[3]);
        double R2 = Double.parseDouble(rsp2.get("fitness").toString());
        double w1 = 0.0;
        double w2 = 0.0;
        double sum = 0.0;

        Map<String, Object> resultMap = new HashMap<String, Object>();
        resultMap.put("tableId", "MicroseismWarningStudy");
        resultMap.put("pk", "\'" + mineId + "\'");
        resultMap.put("entId", "\'" + mineId + "\'");
        resultMap.put("datetime", "\'" + DateUtils.getTime() + "\'");
        resultMap.put("best1", best1);
        resultMap.put("best2", best2);
        resultMap.put("best3", best3);
        resultMap.put("T1", T1);
        resultMap.put("R1", R1);
        resultMap.put("best4", best4);
        resultMap.put("best5", best5);
        resultMap.put("best6", best6);
        resultMap.put("T2", T2);
        resultMap.put("R2", R2);
        resultMap.put("status", 0);
        resultMap.put("w", sum);
        comprehensiveWarningDao.saveMicroseismStudy(resultMap);
        return resultMap;
    }

    /**
     * @Description: 地音综合预警
     * @Param: [mineId, startTime, endTime]
     * @return: java.util.Map<java.lang.String, java.lang.Object>
     * @Author: ChengQi
     * @Date: 2019/4/1
     */
    @Override
    public Map<String, Object> comprehensiveWarningGeosound(String mineId, String startTime, String endTime)
            throws IOException {

        Map<String, Object> result = new HashMap<String, Object>();
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();

        Map<String, Object> treeMap = new HashMap<String, Object>(1);
        treeMap.put("type", "\'" + "Geosound" + "\'");
        treeMap.put("entId", "\'" + mineId + "\'");
        List<Map<String, Object>> tree = removeDuplicateWithOrder(treeDao.queryTreeData(treeMap));
        for (Map<String, Object> map : tree) {
            String deviceId = map.get("deviceId").toString();
            //实时能量一年的量
            long startTimeTimestamp = DateUtils.fomatDateTime(startTime).getTime();
            long endTimeTimestamp = DateUtils.fomatDateTime(endTime).getTime();
            Map<String, Object> parram = new HashMap<String, Object>();
            //获取系统参数
            parram.put("tableId", "sysParameter");
            parram.put("pk", "\'" + mineId + ".Geosound" + "\'");
            parram.put("type", "\'" + "Geosound" + "\'");
            Map<String, Object> sysParameter = microseismDao.querySys(parram);
            parram.remove("pk");

            //获取近一年的微震实时数据
            parram.put("tableId", mineId + "." + "GEOSOUNDREALTIME");
            parram.put("entId", "\'" + mineId + "\'");
            parram.put("startTime", startTimeTimestamp);
            parram.put("endTime", endTimeTimestamp);
            parram.put("deviceId", "\'" + deviceId + "\'");
            parram.remove("pk");

            //List<Map<String, Object>> realList = geosoundDao.queryRealTimeByGeoSound(parram);
            List<Map<String, Object>> realList = queryRealMicroseism(mineId, startTimeTimestamp, endTimeTimestamp);
            for (int i = 0; i < realList.size(); i++) {
                if ((double)realList.get(i).get("emergoa") > 100000) {
                    System.out.println("realList["+i+"]: " + realList.get(i).get("emergoa"));
                }

            }
            //能量平均值
            parram.put("tableId", mineId + "." + "CALGEOEMERGOA");
            List<Map<String, Object>> cList1 = geosoundDao.queryCalEmergoa1(parram);
            System.out.println("cList1.size: " + cList1.size());
            //脉冲因子
            parram.put("tableId", mineId + "." + "CalGeoPulse");
            List<Map<String, Object>> cList2 = geosoundDao.queryCalPulse1(parram);
            System.out.println("cList2.size: " + cList2.size());
            /*******************按时间拉伸数据start*******************/
            if (!cList1.isEmpty() && !cList2.isEmpty()) {
                List<Map<String, Object>> newRealList1 = new ArrayList<>();
                List<Map<String, Object>> newRealList2 = new ArrayList<>();

                if ((long) cList1.get(cList1.size()-1).get("datetime") > (Long) realList.get(0).get("datetime")) {
                    // cList1中的最小时间大于realList中的最大时间
                    for (int i=0; i<cList1.size()-realList.size(); i++) {
                        newRealList1.add(realList.get(0));
                    }
                    for (int i=0; i<realList.size(); i++) {
                        newRealList1.add(realList.get(i));
                    }

                    int len2 = 0;
                    for (int i = 0; i < cList2.size() - 1; i++) {
                        Long datetime1 = (Long) cList2.get(i).get("datetime");
                        Long datetime2 = (Long) cList2.get(i + 1).get("datetime");

                        do {
                            Long datetime3 = (Long) cList1.get(len2).get("datetime");

                            if (datetime3 <= datetime2 && i != cList2.size() - 2) {
                                break;
                            }

                            if (Math.abs(datetime1 - datetime3) > Math.abs(datetime3 - datetime2)) {
                                newRealList2.add(cList2.get(i + 1));
                                len2++;
                            } else {
                                newRealList2.add(cList2.get(i));
                                len2++;
                            }
                        } while (len2 < cList1.size());


                        if (len2 > cList1.size() - 1) {
                            break;
                        }
                    }

                } else if ((long) cList1.get(0).get("datetime") < (Long) realList.get(realList.size()-1).get("datetime")) {
                    // cList1中的最大时间小于realList中的最小时间

                    for (int i=0; i<realList.size(); i++) {
                        newRealList1.add(realList.get(i));
                    }
                    for (int i=0; i<cList1.size()-realList.size(); i++) {
                        newRealList1.add(realList.get(realList.size()-1));
                    }

                    int len2 = 0;
                    for (int i = 0; i < cList2.size() - 1; i++) {
                        Long datetime1 = (Long) cList2.get(i).get("datetime");
                        Long datetime2 = (Long) cList2.get(i + 1).get("datetime");

                        do {
                            Long datetime3 = (Long) cList1.get(len2).get("datetime");

                            if (datetime3 <= datetime2 && i != cList2.size() - 2) {
                                break;
                            }

                            if (Math.abs(datetime1 - datetime3) > Math.abs(datetime3 - datetime2)) {
                                newRealList2.add(cList2.get(i + 1));
                                len2++;
                            } else {
                                newRealList2.add(cList2.get(i));
                                len2++;
                            }
                        } while (len2 < cList1.size());


                        if (len2 > cList1.size() - 1) {
                            break;
                        }
                    }

                } else {
                    int len1 = 0;
                    for (int i = 0; i < realList.size() - 1; i++) {
                        Long datetime1 = (Long) realList.get(i).get("datetime");
                        Long datetime2 = (Long) realList.get(i + 1).get("datetime");
                        //long s1 = Math.abs(datetime1 - 1535378357);
                        //long s2 = Math.abs(1535378357 - datetime2);
                        do {
                            Long datetime3 = (Long) cList1.get(len1).get("datetime");
                            if (datetime3 <= datetime2 && i != realList.size() - 2) {
                                break;
                            }

                            if (Math.abs(datetime1 - datetime3) > Math.abs(datetime3 - datetime2)) {
                                newRealList1.add(realList.get(i + 1));
                                len1++;
                            } else {
                                newRealList1.add(realList.get(i));
                                len1++;
                            }

                        } while (len1 < cList1.size());

                        if (len1 > cList1.size() - 1) {
                            break;
                        }
                    }

                    int len2 = 0;
                    for (int i = 0; i < cList2.size() - 1; i++) {
                        Long datetime1 = (Long) cList2.get(i).get("datetime");
                        Long datetime2 = (Long) cList2.get(i + 1).get("datetime");

                        do {
                            Long datetime3 = (Long) cList1.get(len2).get("datetime");

                            if (datetime3 <= datetime2 && i != cList2.size() - 2) {
                                break;
                            }

                            if (Math.abs(datetime1 - datetime3) > Math.abs(datetime3 - datetime2)) {
                                newRealList2.add(cList2.get(i + 1));
                                len2++;
                            } else {
                                newRealList2.add(cList2.get(i));
                                len2++;
                            }
                        } while (len2 < cList1.size());


                        if (len2 > cList1.size() - 1) {
                            break;
                        }
                    }
                }




            /*loop:
            for (int i = 0; i < cList1.size(); i++) {
                Long datetime1 = (Long) cList1.get(i).get("datetime");
                for (int j = 0; j < realList.size(); j++) {
                    Long datetime2 = (Long) realList.get(j).get("datetime");
                    if (datetime2 > datetime1) {
                        if (j == 0) {
                            newRealList.add(realList.get(j));
                        } else {
                            Long datetime3 = (Long) realList.get(j - 1).get("datetime");
                            if ((datetime2 - datetime1) > (datetime3 - datetime1)) {
                                newRealList.add(realList.get(j - 1));
                            } else {
                                newRealList.add(realList.get(j));
                            }
                        }
                        continue loop;
                    }
                }
            }*/
                /*******************按时间拉伸数据end*******************/

                for (Map<String, Object> map4 : newRealList1) {
                    if ((double)map4.get("emergoa") > 1000000) {
                        System.out.println("realList: " + map4.get("emergoa"));
                    }

                }
                System.out.println("遍历结束");
                //标记大能量事件的下标
                double largeEmergoa = Double.parseDouble(sysParameter.get("LARGEENERGY").toString());
                List<Integer> largeList = new LinkedList<Integer>();
                List<Double> eList = new LinkedList<Double>();
                for (int i = 0; i < newRealList1.size(); i++) {
                    /*eList.add(Double.parseDouble(newRealList1.get(i).get("emergoa").toString()));
                    if (Double.parseDouble(newRealList1.get(i).get("emergoa").toString()) > largeEmergoa) {
                        largeList.add(i);
                    }*/

                    double emergoa = Double.parseDouble(newRealList1.get(i).get("emergoa").toString());
                    eList.add(emergoa);
                    if (emergoa > largeEmergoa) {
                        largeList.add(i);
                    }
                }

                List<Double> newCList1 = new ArrayList<Double>();
                List<Double> newCList2 = new ArrayList<Double>();
                for (int i = 0; i < cList1.size(); i++) {
                    newCList1.add(Double.parseDouble(cList1.get(i).get("avgEmergoa").toString()));
                }
                for (int i = 0; i < newRealList2.size(); i++) {
                    newCList2.add(Double.parseDouble(newRealList2.get(i).get("pulseDeviation").toString()));
                }

                //5.综合预警
                Map<String, Object> reqMap = new HashMap<String, Object>();
                reqMap.put("nengliang", eList);
                reqMap.put("pingci", newCList1);
                reqMap.put("lisan", newCList2);
                reqMap.put("shigu", largeList);
                reqMap.put("population", 20);//种群数量
                reqMap.put("gen", 50);//迭代次数
                reqMap.put("choose", "nengliang,pingci,lisan");
                //Map<String, Object> rsp = pythonAlgorithmUtils.serviceGenetic(reqMap);
                Map<String, Object> rsp = new HashMap<>();
                rsp.put("fitness", 0.9058131375509957);
                rsp.put("best", "31241800.59550093,326245.2106933594,-0.5209596904560759,299,1.53662109375");
                rsp.put("name", "nengliang,pingci,lisan,cishu,w");
                System.out.println("deviceId:" + deviceId + "," + rsp);
                String bests1[] =
                        rsp.get("best").toString().substring(1, rsp.get("best").toString().length() - 1).split(",");
                double best1 = Double.parseDouble(bests1[0]);
                double best2 = Double.parseDouble(bests1[1]);
                double best3 = Double.parseDouble(bests1[2]);
                double T1 = Double.parseDouble(bests1[3]);
                double R1 = Double.parseDouble(rsp.get("fitness").toString());
                Map<String, Object> resultMap = new HashMap<String, Object>();
                resultMap.put("tableId", "GeosoundWarningStudy");
                resultMap.put("pk", "\'" + mineId + ".:." + deviceId + "\'");
                resultMap.put("entId", "\'" + mineId + "\'");
                resultMap.put("datetime", DateUtils.fomatDateTime(DateUtils.getTime()).getTime());
                resultMap.put("best1", best1);
                resultMap.put("best2", best2);
                resultMap.put("best3", best3);
                resultMap.put("T1", T1);
                resultMap.put("R1", R1);
                resultMap.put("status", true);
                resultMap.put("deviceId", "\'"+deviceId+"\'");
                list.add(resultMap);
                comprehensiveWarningDao.saveGeosoundStudy(resultMap);
            }
        }
        result.put("list", list);
        return result;
    }

    /**
     * @Description: 单系统综合预警-液压支架
     * @Param: [mineId, startTime, endTime]
     * @return: java.util.Map<java.lang.String, java.lang.Object>
     * @Author: ChengQi
     * @Date: 2019/4/1
     */
    @Override
    public Map<String, Object> comprehensiveWarningHy(String mineId, String startTime, String endTime)
            throws IOException {

        Map<String, Object> result = new HashMap<String, Object>();
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();

        Map<String, Object> treeMap = new HashMap<String, Object>(1);
        treeMap.put("type", "\'" + "hydraulicSupport" + "\'");
        treeMap.put("entId", "\'" + mineId + "\'");
        List<Map<String, Object>> tree = removeDuplicateWithOrder(treeDao.queryTreeData(treeMap));
        for (Map<String, Object> map : tree) {
            String deviceId = map.get("deviceId").toString();
            //String deviceId = "m004D5";
            System.out.println("deviceId: " + deviceId);
            //实时能量一年的量
            long startTimeTimestamp = DateUtils.fomatDateTime(startTime).getTime();
            long endTimeTimestamp = DateUtils.fomatDateTime(endTime).getTime();
            Map<String, Object> parram = new HashMap<String, Object>();
            //获取系统参数
            parram.put("tableId", "sysParameter");
            parram.put("pk", "\'" + mineId + ".Microseism" + "\'");
            parram.put("type", "\'" + "Microseism" + "\'");
            Map<String, Object> sysParameter = microseismDao.querySys(parram);
            parram.remove("pk");

            //获取近一年的微震实时数据
            parram.put("tableId", mineId + "." + "MICROSEISMREALTIME");
            parram.put("entId", "\'" + mineId + "\'");
            parram.put("startTime", startTimeTimestamp);
            parram.put("endTime", endTimeTimestamp);
            parram.put("deviceId", "\'" + deviceId + "\'");

            List<Map<String, Object>> realList = queryRealMicroseism(mineId, startTimeTimestamp, endTimeTimestamp);

            // 查询液压支架频次
            parram.put("tableId", mineId + "." + "CALHYFREQUENCY");
            List<Map<String, Object>> cList1 = hydraulicsupportDao.queryFrequency(parram);

            // 查询闪烁间隔危险度
            parram.put("tableId", mineId + "." + "FLICKERINTERVALRISK");
            List<Map<String, Object>> cList2 = hydraulicsupportDao.queryFlicker(parram);

            if (!cList1.isEmpty() && !cList2.isEmpty()) {
                List<Map<String, Object>> newRealList1 = new ArrayList<Map<String, Object>>();
                List<Map<String, Object>> newRealList2 = new ArrayList<>();
                /*******************按时间拉伸数据start*******************/
                int len1 = 0;
                for (int i = 0; i < realList.size() - 1; i++) {
                    Long datetime1 = (Long) realList.get(i).get("datetime");
                    Long datetime2 = (Long) realList.get(i + 1).get("datetime");

                    do {
                        Long datetime3 = (Long) cList1.get(len1).get("datetime");
                        if (datetime3 <= datetime2 && i != realList.size() - 2) {
                            break;
                        }

                        if (Math.abs(datetime1 - datetime3) > Math.abs(datetime3 - datetime2)) {
                            newRealList1.add(realList.get(i + 1));
                            len1++;
                        } else {
                            newRealList1.add(realList.get(i));
                            len1++;
                        }
                    } while (len1 < cList1.size());

                    if (len1 > cList1.size() - 1) {
                        break;
                    }
                }

                int len2 = 0;
                for (int i = 0; i < cList2.size() - 1; i++) {
                    Long datetime1 = (Long) cList2.get(i).get("datetime");
                    Long datetime2 = (Long) cList2.get(i + 1).get("datetime");

                    do {
                        Long datetime3 = (Long) cList1.get(len2).get("datetime");

                        if (datetime3 <= datetime2 && i != cList2.size() - 2) {
                            break;
                        }

                        if (Math.abs(datetime1 - datetime3) > Math.abs(datetime3 - datetime2)) {
                            newRealList2.add(cList2.get(i + 1));
                            len2++;
                        } else {
                            newRealList2.add(cList2.get(i));
                            len2++;
                        }
                    } while (len2 < cList1.size());


                    if (len2 > cList1.size() - 1) {
                        break;
                    }
                }


                /*******************按时间拉伸数据end*******************/
                //标记大能量事件的下标
                double largeEmergoa = Double.parseDouble(sysParameter.get("LARGEENERGY").toString());
                List<Integer> largeList = new LinkedList<Integer>();
                List<Double> eList = new LinkedList<Double>();
                for (int i = 0; i < newRealList1.size(); i++) {
                    double emergoa = Double.parseDouble(newRealList1.get(i).get("emergoa").toString());
                    eList.add(emergoa);

                    if (emergoa > largeEmergoa) {
                        largeList.add(i);
                    }
                }

                List<Double> newCList1 = new ArrayList<Double>();
                List<Double> newCList2 = new ArrayList<Double>();
                for (int i = 0; i < cList1.size(); i++) {
                    newCList1.add(Double.parseDouble(cList1.get(i).get("leftFrequency").toString()));
                }
                for (int i = 0; i < newRealList2.size(); i++) {
                    newCList2.add(Double.parseDouble(newRealList2.get(i).get("I").toString()));
                }

                //5.综合预警
                Map<String, Object> reqMap = new HashMap<String, Object>();
                reqMap.put("nengliang", eList);
                reqMap.put("pingci", newCList1);
                reqMap.put("lisan", newCList2);
                reqMap.put("shigu", largeList);
                reqMap.put("population", 20);//种群数量
                reqMap.put("gen", 50);//迭代次数
                reqMap.put("choose", "nengliang,pingci,lisan");
                Map<String, Object> rsp = pythonAlgorithmUtils.serviceGenetic(reqMap);
                System.out.println("deviceId:" + deviceId + "," + rsp);
                String bests1[] =
                        rsp.get("best").toString().substring(1, rsp.get("best").toString().length() - 1).split(",");
                double best1 = Double.parseDouble(bests1[0]);
                double best2 = Double.parseDouble(bests1[1]);
                double best3 = Double.parseDouble(bests1[2]);
                double T1 = Double.parseDouble(bests1[3]);
                double R1 = Double.parseDouble(rsp.get("fitness").toString());
                Map<String, Object> resultMap = new HashMap<String, Object>();
                resultMap.put("tableId", "HydraulicsupportWarningStudy");
                resultMap.put("pk", "\'" + mineId + ".:." + deviceId + "\'");
                resultMap.put("entId", "\'" + mineId + "\'");
                resultMap.put("datetime", "\'" + DateUtils.fomatDateTime(DateUtils.getTime()).getTime() + "\'");
                resultMap.put("best1", best1);
                resultMap.put("best2", best2);
                resultMap.put("best3", best3);
                resultMap.put("T1", T1);
                resultMap.put("R1", R1);
                resultMap.put("status", 0);
                resultMap.put("deviceId", "\'" + deviceId + "\'");
                list.add(resultMap);
                comprehensiveWarningDao.saveGeosoundStudy(resultMap);
            }
        }
        result.put("list", list);
        return result;
    }


    /**
     * @Description: 查询微震实时数据
     * @Param: [mineId, startTimeTimestamp, endTimeTimestamp]
     * @return: java.util.List<java.util.Map < java.lang.String, java.lang.Object>>
     * @Author: ChengQi
     * @Date: 2019/4/1
     */
    private List<Map<String, Object>> queryRealMicroseism(String mineId, long startTimeTimestamp,
                                                          long endTimeTimestamp) {
        Map<String, Object> parram = new HashMap<String, Object>();
        parram.put("tableId", mineId + "." + "MicroseismRealTime");
        parram.put("entId", "\'" + mineId + "\'");
        parram.put("startTime", "\'" + startTimeTimestamp + "\'");
        parram.put("endTime", "\'" + endTimeTimestamp + "\'");
        return microseismDao.queryRealMicroseism(parram);
    }
}
